package logicalOperation;

import java.util.Vector;

public class And implements Logicaloperation
{
	int index;
	int index1;
	public void searchColumn(int index) 
	{
		this.index = index;
	}
	
	public void searchColumn(int index,int index1) 
	{
		this.index = index;
		this.index1 = index1;
	}
	
	public String[] getResult(String[] string1, String[] string2) 
	{
		Vector<Object> Result = new Vector<Object>();
		
		String[] str1 = getRecordOfSearchColumn(string1,index);
		String[] str2 = getRecordOfSearchColumn(string2,index1);
		for(int i=0;i<str1.length;i++)
		{
			for(int j=0;j<str2.length;j++)
			{
				if(str1[i].equals(str2[j]))
				{
					Result.add(string1[i]);
					break;
				}
			}
		}
		String[] temp = new String[Result.size()];
		Result.toArray(temp);
		return temp;
	}
	
	String [] getRecordOfSearchColumn(String [] str,int index)
	{
		Vector<Object> Result = new Vector<Object>();
		for(int i=0;i<str.length;i++)
		{
			String [] tempstr = str[i].split("\t");
			Result.add(tempstr[index]);
		}
		String[] temp = new String[Result.size()];
		Result.toArray(temp);
		return temp;
	}
	public boolean getResult(boolean string1, boolean string2) 
	{
		return string1 & string2;
	}
	public static void main(String []a)
	{
		String string1 []= {"111\t123\t124","113\t123\t124"};
		String string2 []= {"111\t125\t126","113\t125\t127","112\t125\t128"};
		And and = new And();
		and.searchColumn(0);
		String [] temp = and.getResult(string1, string2);
		for(int i=0;i<temp.length;i++)
			System.out.println(temp[i]);
	}
}
